package com.snuproject.lgt.imgtrans;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.content.Context;
import android.opengl.GLSurfaceView.Renderer;
import android.opengl.GLU;

public class GL3DImageRenderer  implements Renderer {

	 public static float BASE_DEPTH_Z = -20;
	 public static float MIN_DEPTH_Z = -10;
	 public static float MAX_DEPTH_Z = -100;
	 
    private Context mContext;
    
	public GL3DImageRenderer(Context context) {
        mContext = context;
		
	}

    public void onDrawFrame(GL10 gl) {
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        gl.glLoadIdentity();
    }

    public void onSurfaceChanged(GL10 gl, int width, int height) {
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL10.GL_PROJECTION);
		gl.glLoadIdentity();

		GLU.gluPerspective(gl, 45.0f, (float) width / height, 1.0f, -MAX_DEPTH_Z);
		        
		gl.glMatrixMode(GL10.GL_MODELVIEW);
		gl.glLoadIdentity();
    }

	public void onSurfaceCreated(GL10 gl, EGLConfig config) {

		  gl.glShadeModel(GL10.GL_SMOOTH);
		  gl.glEnable(GL10.GL_POINT_SMOOTH);
		  gl.glEnable(GL10.GL_LINE_SMOOTH);
		  gl.glHint(GL10.GL_POINT_SMOOTH_HINT, GL10.GL_NICEST);
		  gl.glHint(GL10.GL_LINE_SMOOTH_HINT, GL10.GL_NICEST);
		  gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST);
		  gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
		  

		  gl.glClearDepthf(1.0f);
		  gl.glEnable(GL10.GL_DEPTH_TEST);
		  gl.glDepthFunc(GL10.GL_LEQUAL);

		  gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
		
	}
	

}
